
DEFINE VARIABLE i AS INTEGER.
DEFINE VARIABLE j AS INTEGER.
DEFINE VARIABLE grp AS CHARACTER .
DEFINE VARIABLE str AS CHARACTER FORMAT "X(256)" .
/*  Test 
grp = "PT2,PT3,PT4,BM2,BM3,BM4,EC2,EC4,EC8,RT2,MF2,PL2,PL3,PL4,MC2,MC3,MC4,PM2,PM3,PM4,PO2,PO3,PO4,PO5,VD2,VD3,VD4,VD5," + 
      "CU2,CU3,CU4,MT2,SO2,SO3,SO4,SO5,SO6,ST1,ST2,ST3,ST4,ST6,ST7,AP2,AR2,CO2,GL2,GL3,IT,DR2,DR3,BM6,DEL" .
*/
/*    Train 
grp = "MIS,ITM-M,ITM-C,BOM-M,BOM-Q,ECN-M,ECN-Q,MKT-M,MKT-Q,SAL-M,SAL-C,SAL-Q,SAL-S," + 
      "PMC-M,PMC-Q,PMC-C,PUR-M,PUR-Q,PUR-C,STK-M,STK-Q,STK-W,STK-S,STK-P,STK-R,STK-C,GL,AR-M,AP-M,CST-M,MFG-M,DEL" .
*/
/*    PC  
grp = "PT2,PT3,PT4,BM2,BM3,BM4,EC2,EC4,EC8,RT2,MF2,PL2,PL3,PL4,MC2,MC3,MC4,PM2,PM3,PM4,PO2,PO3,PO4,PO5,VD2,VD3,VD4,VD5," + 
      "ST1,ST2,ST3,ST4,ST5,ST6,ST7,CU2,CU3,SO2,SO3,SO4,SO5,SO6,MF2,DR2,DR3,AP2,AR2,CO2,GL2,IT,BM6" .
*/

/*
DO i = 1 TO NUM-ENTRIES(grp) WITH FRAME a STREAM-IO WIDTH 120 :
    CREATE mnd_det .
    ASSIGN
        mnd_nbr = "50"
        mnd_select = i
        mnd_exec = "50." + STRING(i)
        mnd_label = ENTRY(i, grp)
        mnd_canrun = ENTRY(i, grp).

    CREATE mnt_det .
    ASSIGN
        mnt_lang = "ch"
        mnt_nbr = "50"
        mnt_select = i
        mnt_label = ENTRY(i, grp) .
END.
*/

OUTPUT TO c:\pc-menu-security.txt .

DO i = 1 TO NUM-ENTRIES(grp) WITH FRAME a STREAM-IO WIDTH 120 :

    j = 1.
    FOR EACH mnd_det NO-LOCK WHERE LOOKUP( ENTRY(i,grp), mnd_canrun ) > 0 AND mnd_nbr <> "50" ,
        EACH mnt_det NO-LOCK WHERE mnt_lang = "ch" AND mnt_nbr = mnd_nbr AND mnt_select = mnd_select :

        str = STRING(i) + "," + STRING(j) + "," + mnd_label + "," + mnd_exec + "," + ENTRY(i,grp) + "," + mnt_label .
        PUT str SKIP .
        j = j + 1.
/*        DISPLAY ENTRY(i,grp) mnd_nbr mnd_select mnt_label mnd_exec WITH STREAM-IO .   */

    END.

END.

OUTPUT CLOSE.

/*
DEFINE VARIABLE sel LIKE mnd_select.
DEFINE VARIABLE exec LIKE mnd_exec.
DEFINE VARIABLE lbl1 LIKE mnd_label.
DEFINE VARIABLE sec LIKE mnd_canrun .
DEFINE VARIABLE lbl2 LIKE mnt_label.
    
DEFINE VARIABLE n AS INTEGER.

INPUT FROM VALUE(SEARCH("c:\train-menu-security.txt")).

n = 0 .

DO WHILE TRUE :


    IMPORT DELIMITER "," i j lbl1 exec sec lbl2 NO-ERROR .

/*  DISPLAY i j lbl1 exec sec lbl2 WITH STREAM-IO . */

    CREATE mnd_det .
    ASSIGN 
        mnd_nbr = "50." + STRING(i)
        mnd_select = j
        mnd_label = lbl1
        mnd_exec = exec
        mnd_canrun = sec.

    CREATE mnt_det .
    ASSIGN
        mnt_nbr = "50." + STRING(i)
        mnt_select = j
        mnt_label = lbl2
        mnt_lang = "ch".

    n = n + 1.

    IF n >= 3158 THEN LEAVE.

END.
INPUT CLOSE.
*/
